<%@page import="com.alibaba.fastjson.JSON"%>
<%@page import="java.util.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.openkoala.security.shiro.CurrentUser"%>
<%@page import="com.dhcc.DRGsHosp.infra.util.GlobalData"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/commons/taglibs.jsp"%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%--<%@include file="/commons/metas.jsp"%>--%>
    <title>DRG住院医疗服务监测与分析系统</title>
    <%@include file="/commons/statics.jsp"%>
	<link rel="shortcut icon" href="images/logo_big.png" type="image/x-icon" />
	<%
		String contextPath = request.getContextPath();
		String roleName=CurrentUser.getRoleName();
		String userCount=CurrentUser.getUserAccount();
		String deps="";
        if("科室".equals(roleName)){
        	deps =CurrentUser.getDeps();
        }
        // 访问系统变量
        Map<String,String> sysConfig = GlobalData.sysConfig ;
        String sysConfigJson = JSON.toJSONString(sysConfig);
        
        Map<String, List<Map<String, Object>>> sysDictionary=GlobalData.sysDictionary;
        String sysDictionaryJson=JSON.toJSONString(sysDictionary);
	%>
	<style type="text/css">
	.msg_header{
	    border-bottom: 1px solid #ccc;
	    padding: 4px 8px !important;
	    font-size: 12px;
	    line-height: 24px;
	    color: #000;
	    font-weight: 700;
	    color: white;
	    min-width: 130px;
	}
	
	</style>
</head>
<body> 
	<input type="hidden" id="roleId" value="${roleId}" />
	<input type="hidden" id="roleName_id" value="<%=roleName %>"/>
	<input type="hidden" id="userCount_id" value="<%=userCount %>"/>
	<input type="hidden" id="deps_id" value="<%=deps %>"/>
    <%-- 顶部 --%>
	<div class="g-head topmenu" style=" z-index: 500;">
	    <nav class="navcq navbar navbar-default bgimage">
	        
	        <div class="collapse navbar-collapse navbar-ex1-collapse">
                <div class="btn-group navbar-right navbtncq">
                    <div data-toggle="dropdown" id='btn1'><i class="glyphicon glyphicon-cog"></i></div>
                    
                    <ul class="dropdown-menu" id="userManager" style="min-width: 0;background-color: rgb(23, 24, 25);">
                        <li data-target="loginOut"><a href="#"><i href="#" class="glyphicon glyphicon-off"></i>退出</a></li>
                        <li data-target="modifyPwd"><a href="#"><i href="#" class="glyphicon glyphicon-pencil"></i>更改密码</a></li>
                        <li data-toggle="modal" data-target="#changeEmailOfUser"><a href="#"><i href="#" class="glyphicon glyphicon-envelope"></i>更改邮箱</a></li>
                        <li data-toggle="modal" data-target="#changeTelePhoneOfUser"><a href="#"><i href="#" class="glyphicon glyphicon-earphone"></i>更改电话</a></li>
                        <li data-target="clearCache"><a href="#"><i href="#" class="glyphicon glyphicon-repeat"></i>清除缓存</a></li>
                    </ul>
                </div>
                <div class="btn-group navbar-right navbtncq" style="padding: 8px;">
                    <div data-toggle="dropdown" id='btnNotification'><i class="fa fa-bell" style="color: #fff;font-size: 16px;line-height: 41px;"></i></div>
                    <ul class="dropdown-menu" id="notificationUl" style="min-width: 0;background-color: rgb(23, 24, 25);">
                      <li class="msg_header"><i class="icon-bell" style="padding: 4px 4px;"></i>待办事项</li>
                    </ul>
                </div>
                <!-- 查询条件样式 ECQ -->
				<div class="btn-group navbar-right navbtncq"  style="padding:10px 22px;"  id="setSysConfig" >
                    <span style="font-size: 12px;"  class=" icon-medkit">&#12288;配置</span>
                </div>
                <!--角色信息-->
                <div class="btn-group navbar-right" id="roleChange" style="padding:10px;"  title="切换角色">
                    <label for = "roles" class = "user_name">角色: </label>
	            	<span id="roles" style="font-size: 12px;font-weight: bold;"><ks:user property="roleName" /></span>
                    <ul class="dropdown-menu" id="allRolesId"></ul>
                </div>
	            <!-- 账号信息 -->
	            <div class="btn-group navbar-right">
                    <span>
                        <!-- 为了不改变页面布局-->
                    </span>
                    <a href="#" id="userInfo"  onclick="showDetail()" class="glyphicon glyphicon-user" style="color: #fff;text-decoration: none; -moz-osx-font-smoothing:none;top:-1px;font-weight: bold; font-size: 12px;padding: 22px 10px 22px 10px;"  title="查看个人信息"  >&nbsp;<span style="font-family:microsoft yahei"><ks:user property="name" /></span>
                    </a>
                    &nbsp; &nbsp;
                </div>
                <!-- 查询条件样式 SCQ -->
<!--                 修改1.医政-科室指标监测-年度趋势图显示不正确 2.查询15年11月数据后，点击任意指标的趋势图按钮，显示15年各月份的数据By Ruanshuli At 2017年2月27日09:54:29 
 -->                
                    <div class="btn-group navbar-right navbtncq" id="searchbtncq" style="display:none;font-weight: bold;">
                        <div class="t" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="glyphicon glyphicon-search"></i>查询&条件<span class="caret"></span>&nbsp;&nbsp;<span class="time_id">2015.11</span></div>
                        <div class="dropdown-menu searchcq" id="searchcq">
                            <div>
                                <div class="ti"><i class="fa fa-users" ></i>监测对象：</div>
                                <div class="ci atag"><a class="active" data-value="0" >全体出院病例</a><a data-value="1">医保出院病例</a></div>
                            </div>
                            <div >
                                <div class="ti"><i class="fa fa-flag"></i>DRG标杆：</div>
                                <div class="ci"><a class="active">年度标杆</a></div>
                            </div>
                            <div style="position:relative;" >
                                <div class="ti"><i class="fa fa-calendar"></i>监测时间：</div>
                                <div class="ci atag"><a class="active" data-value="2014Y12M" data-type="M">2014.12</a><a data-value="2014Y12MC" data-type="MC">2014.01~2014.12</a><a data-type="custom">自定义</a>
	                            				<div id="date-custom" style="position:absolute;display:none;right:0px;top:-3px;"><input id="date-from" style="width:60px;">~<input id="date-to" style="width:60px;"></div></div>
                            </div>
                            <div>
                                <div class="ti"><i class="fa fa-exchange"></i>比较类型：</div>
                                <div class="ci atag">
                                	<a class="active" data-value="year" style="display: none;">同比</a>
                                	<a data-value="month" style="display: none;">环比</a>
                                	<a data-value="hosp" style="display: none;">院内均值</a>
                                	<span style="position:relative;" id="manager_span_id">
                                		<a data-value="manage" code-data = "manager_inner" data-toggle="tooltip" data-placement="right" title="管理目标值" style="display: none;position:relative;">绩效比&nbsp;
                                			<i class="fa fa-caret-down" aria-hidden="true" title="Toggle dropdown menu"></i>
                                		</a>
                                		<ul class = "managelist"></ul>
                                	</span>
                                	<span style="position:relative;" id="std_span_id">
                                		<a data-value="std" code-data = "std_computer" data-toggle="tooltip" data-placement="right" title="病组标杆" style="display: none;position:relative;">标杆比&nbsp;
                               				<i class="fa fa-caret-down" aria-hidden="true" title="Toggle dropdown menu"></i>
                                		</a>
                                		<ul class = "morestd"></ul>
                                	</span>
                                	<a data-value="none" style="display: none;">无</a>
                                </div>
                            </div>
                            <div class="b"><button class="search" onclick="searchByCondition()"><i class="glyphicon glyphicon-search"></i>查询</button></div>
                        </div>
                    </div>
	        </div>
	    </nav>
	</div>
	
	<%-- 中间 --%>
	<div class="g-body">
		<!-- 左边导航 -->
		<div id="cbp-spmenu-s1" style = "overflow-x: hidden;z-index: 465;" class = "cbp-spmenu cbp-spmenu-vertical cbp-spmenu-left menulcq">
		    <div class=" g-sidec" style="width:220px;">
		        <ul class="nav nav-stacked first-level-menu" >
		       		
		        </ul>
		    </div>
		</div>
	    <!-- 右边内容 -->
	    <div class="g-mainc brightcq" style="overflow-x: hidden;">
	    	<div id="navDiv" style="z-index:460">
	    		<div id="prevNavTab"><i class="fa fa-chevron-left"></i></div>
		        <ul class="tabcq nav nav-tabs" id="navTabs">
		            <li class="active" style="overflow:hidden; white-space:nowrap;"><a href="#home" data-toggle="tab" ondragstart="return false" style="overflow:hidden;font-family:microsoft yahei"><i class="glyphicon  glyphicon-home"></i><span>首页</span></a></li>
		        </ul>
		        <div id="nextNavTab"><i class="fa fa-chevron-right"></i></div>
	        </div>
	        <div class="tab-content" id="tabContent">
	            <div id="home" class="tab-pane active"></div>
	        </div>
	    </div>
	    <div class="menulscq" id="showLeft" align="center">
	    </div>
	</div>
    <%-- 底部 --%>
	<div id="footer" class="g-foot footcq"><span>Copyright © 2013-<%=new SimpleDateFormat("yyyy").format(new Date()) %> 东华软件股份公司 V3.1.1正式版 &nbsp;&nbsp;<a href = 'javascript:changelog()'>更新日志</a></span></div>
	<div id="console_drgs" style="display: none;"><section><span></span>&nbsp;<i class="fa fa-terminal"></i></section></div>
</body>
<script src="<%=contextPath%>/js/index/global.js"></script>
<script src="<%=contextPath%>/js/index/sysNotification.js"></script>
<script src="<%=contextPath%>/js/index/setHospGroup.js"></script>
<script src="<%=contextPath%>/js/index/setHomePage.js"></script>
<script src="<%=contextPath%>/js/index/setStdManager.js"></script>
<script src="<%=contextPath%>/js/menu/classie.js"></script>
<!-- 顶部导航条js -->
<script type="text/javascript">
sysConfig = '<%=sysConfigJson%>' ;//系统配置信息
diction = '<%=sysDictionaryJson%>' ;//系统配置信息
sysConfig = jQuery.parseJSON(sysConfig) ;
diction = jQuery.parseJSON(diction) ;
var selectedHospCode ='';//选中的院区名称
var selectedHospName ='';//选中的院区名称
var selectedGroupScheme ='';//选中的分组
var selectedStdType ='';//选中的测算标杆
var hospCnt=1;//院区个数
var contextPath = '${pageContext.request.contextPath}';
var roleName = null;
var adjustUrl = {};
var commonLayerConfig;
var doctorSetConfig;
jQuery(document).ready(function() {		
	// var topmenu = jQuery(".topmenu");
	// var topmenu_top = topmenu.offset().top;
	// var tap = jQuery("#navDiv");
	// var tap_top = tap.offset().top;
	// reset_topmenu_top(topmenu, topmenu_top);
	// reset_tap_top(tap, tap_top);
	// jQuery(window).scroll(function() {
	// 	reset_topmenu_top(topmenu, topmenu_top);
	// 	reset_tap_top(tap, tap_top);
	// });
	
	var $navTab = $('ul#navTabs');
	var $navDiv = $('div#navDiv');
	
	$('#prevNavTab').click(function(){
		if ($navTab.position().left < -156 ) {
			$navTab.css('left',$navTab.position().left+156+'px');
			$('#nextNavTab').addClass('haveTab');
		} else if($navTab.position().left < 0 ){
			$navTab.css('left','0px');
			$('#prevNavTab').removeClass('haveTab');
			$('#nextNavTab').addClass('haveTab');
		}
	})
	$('#nextNavTab').click(function(e){
		if (($navTab.children().length*156 + $navTab.position().left) > $navDiv.width()) {
			$navTab.css('left',$navTab.position().left-156+'px');
			$('#prevNavTab').addClass('haveTab');
			if (($navTab.children().length*156 + $navTab.position().left) <= $navDiv.width()) {
				$('#nextNavTab').removeClass('haveTab');
			}
		} else {
			$('#nextNavTab').removeClass('haveTab');
		}
	});	
});
function reset_topmenu_top(topmenu, topmenu_top) {
	var document_scroll_top = jQuery(document).scrollTop();
	if (document_scroll_top > topmenu_top) {
		topmenu.css('top', document_scroll_top);
	}
	if (document_scroll_top <= topmenu_top) {
		topmenu.css('top', topmenu_top);
	}
}

function reset_tap_top(tap, tap_top) {
	var document_scroll_top = jQuery(document).scrollTop();
	if (document_scroll_top > tap_top) {
		tap.css('top', document_scroll_top + 58);
	}
	if (document_scroll_top <= tap_top) {
		tap.css('top', tap_top + document_scroll_top);
	}
}

	/*判断一个对象是否数组*/
	function isArray(o) {
		return '[object Array]' == Object.prototype.toString.call(o);
	}
	//获取分层配置的层级
	function getLayerConfig() {
		var levels = [];
		var data=sysConfig.DEP_LINE_LAYER;
		if(data){
			levels=data.split(',');
		}
		return levels;
	}
	//获取医生配置
	function getDoctorConfig() {
		var doctorSet = [];
		var data=sysConfig.DOCTOR_SET;
		if(data){
			doctorSet=data.split(',');
		}
		return doctorSet;
	}
	// 更改联系电话
	// ------------ changeTelePhoneOfUser start ---------------
	$(function() {
		$('#userManager').find("li[data-target=#changeTelePhoneOfUser]").click(function() {
			$.get(contextPath + '/pages/auth/user-changeTelePhone.jsp').done(function(data) {
				var dialog = $(data);
				var oldTelePhone = dialog.find('#oldTelePhone');
				var newTelePhone = dialog.find('#newTelePhone');
				var confirmPassword = dialog.find('#confirmPassword');

				dialog.find('#changeTelePhoneOfUserSave').on('click', function() {
					if (!Validator.Validate(dialog.find('form')[0], 3))
						return;
					var data = {};
					data['telePhone'] = newTelePhone.val();
					data['userPassword'] = confirmPassword.val();
					$.post(contextPath + '/auth/currentUser/changeUserTelePhone.dhc', data, function(data) {
						if (data.success) {
							drgUI.success('更改联系电话成功');
							dialog.modal('hide');
						} else {
							drgUI.error(data.errorMessage);
						}
					});
				}).end().modal({
					keyboard : false
				}).on({
					'hidden.bs.modal' : function() {
						$(this).remove();
					},
					'complete' : function() {
						drgUI.success('更改联系电话成功!');
						$(this).modal('hide');
					}
				});
				//兼容IE8 IE9
				if (window.ActiveXObject) {
					if (parseInt(navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/)[1]) < 10) {
						dialog.trigger('shown.bs.modal');
					}
				}
			});
		});
	});
	//退出设置
	$(function() {
		$('#userManager').find("li[data-target=loginOut]").click(function() {
			drgUI.confirm({
				content : '确定要退出该用户吗?',
				callSure : function() {
					drgUI.drgLogOut();
				}
			});
		});
	});
	// ------------ changeTelePhoneOfUser end ---------------

	// 更改邮箱
	// ------------ changeEmailOfUser start ---------------
	$(function() {
		$('#userManager').find("li[data-target=#changeEmailOfUser]").click(function() {
			$.get(contextPath + '/pages/auth/user-changeEmail.jsp').done(function(data) {
				var dialog = $(data);
				var oldEmail = dialog.find('#oldEmail');
				var newEmail = dialog.find('#newEmail');
				var confirmPassword = dialog.find('#confirmPassword');

				dialog.find('#changeEmailOfUserSave').on('click', function() {
					if (!Validator.Validate(dialog.find('form')[0], 3))
						return;
					var data = {};
					data['email'] = newEmail.val();
					data['userPassword'] = confirmPassword.val();
					$.post(contextPath + '/auth/currentUser/changeUserEmail.dhc', data, function(data) {
						if (data.success) {
							drgUI.success('更改邮箱成功!');
							dialog.modal('hide');
						} else {
							drgUI.error(data.errorMessage);
						}
					});
				}).end().modal({
					keyboard : false
				}).on({
					'hidden.bs.modal' : function() {
						$(this).remove();
					},
					'complete' : function() {
						drgUI.success('更改邮箱成功!');
						$(this).modal('hide');
					}
				});
				//兼容IE8 IE9
				if (window.ActiveXObject) {
					if (parseInt(navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/)[1]) < 10) {
						dialog.trigger('shown.bs.modal');
					}
				}
			});
		});
	});
	// ------------ changeEmailOfUser end ---------------

	/*切换角色*/
	$(function() {
		// ------------ switchOverRoleOfUser start ---------------
		$('#roleChange').click(function() {
			$.get(contextPath + '/pages/auth/role-switch.jsp').done(function(data) {
				var dialog = $(data);
				dialog.find('#toggle').on('click', function() {
					var items = dialog.find('.selectRoleGrid').data('koala.grid').selectedRows();
					if (items.length == 0) {
						drgUI.success('请选择要切换的角色');
						return;
					}
					if (items.length > 1) {
						drgUI.warning('只能选择一个角色!');
						return;
					}
					$.post(contextPath + '/auth/currentUser/switchOverRoleOfUser.dhc', "roleName=" + items[0].name, function(data) {
						if (data.success) {
							drgUI.success('切换角色成功！');
							window.location.href = contextPath + "/index.dhc";
						} else {
							drgUI.error('系统报错!');
						}
					});

				})
				dialog.modal({
					keyboard : false
				}).on({
					'hidden.bs.modal' : function() {
						$(this).remove();
					},

					'shown.bs.modal' : function() { //弹窗初始化完毕后，初始化url选择表格
						var columns = [ {
							title : "角色名称",
							name : "name",
							width : 250
						}, {
							title : "角色描述",
							name : "description",
							width : 250
						} ];

						dialog.find('.selectRoleGrid').grid({
							identity : 'id',
							columns : columns,
							url : contextPath + '/auth/currentUser/pagingQueryRolesOfUser.dhc'
						});
					}

				});
				//兼容IE8 IE9
				if (window.ActiveXObject) {
					if (parseInt(navigator.userAgent.toLowerCase().match(/msie ([\d.]+)/)[1]) < 10) {
						dialog.trigger('shown.bs.modal');
					}
				}
			});
			// ------------ switchOverRoleOfUser end ---------------
		});
	});

	/**
	 * 显示详细信息
	 */
	var showDetail = function() {
		var userInfo = $("#userInfo").find("span").html();
		var thiz = $(this), mark = thiz.attr('mark');
		mark = openTab('/pages/auth/currentUser-info.jsp', userInfo, 'currentUser');
		if (mark) {
			thiz.attr("mark", mark);
		}
	};

	/* 查询条件一直显示 SCQ */
	$(function() {
		//分组器版本控制
		$("#group_version_id").on('click', function() {
			$(this).prev().attr('class', '');
			$(this).css('background', '#393939');
		});
		$("#group_version_id").prev().on('click', function() {
			$("#group_version_id").css('background', '#747474');
		});
		//只有首页的时候 绩效比才有下来列表 其他情况下 没有只有默认绩效值
		$("#searchbtncq").bind("click", function(e) {
			if (tabId == "home" && $('#roleName_id').val() == "医政") {
				$("#searchcq").children().eq(3).find("div.ci a").eq(3).find("i").fadeIn();
			} else {
				$("#searchcq").children().eq(3).find("div.ci a").eq(3).find("i").fadeOut();
				$("#searchcq").children().eq(3).find("div.ci a").eq(3).attr("code-data", "manager_inner");
				$("#searchcq").children().eq(3).find("div.ci a").eq(3).attr("data-original-title", "管理目标值");
				$("#searchcq").children().eq(3).find("div.ci").eq(3).find("div.tooltip-inner").html("管理目标值");
				$("#searchcq").children().eq(3).find("ul.managelist").css("display", "none");
			}
		});
		//绑定左边菜单点击事件
		$(document).bind("click", function(e) {
			var target = $(e.target);
			if (target.closest("#searchcq").length != 0) {
				$("#searchbtncq").addClass("open");
			} else {
				$("#searchbtncq").removeClass("open");
			}
			/*  //绩效比 区域外 添加点击事件 
			 if(target.closest("#manager_span_id").length != 0&&$("#searchcq").children().eq(3).find("div.ci a").eq(3).find("i").css('display')!="none"){ 
			 	$("#searchcq .managelist").addClass("open");
			 }else{
			 	$("#searchcq .managelist").removeClass("open");
			 } 
			//标杆比 区域外 添加点击事件
			 if(target.closest("#std_span_id").length != 0){ 
			 	$("#searchcq .morestd").css("display","block");
			 }else{
			 	$("#searchcq .morestd").css("display","none");
			 }  */
		})

		//$("#searchbtncq").fadeOut();
	});
	//加载时间框
	$("#searchcq [data-toggle='tooltip']").tooltip();
	//日期选择器
	$("#date-from").datetimepicker({
		format : "yyyy.mm",
		autoclose : true,
		todayBtn : true,
		minView : 3,
		startView : 3,
		language : 'zh-CN'
	}).on('changeDate', function() {
		dateCustom();
	});
	$("#date-to").datetimepicker({
		format : "yyyy.mm",
		autoclose : true,
		todayBtn : true,
		minView : 3,
		startView : 3,
		language : 'zh-CN',
	}).on('changeDate', function() {
		dateCustom();
	});

	var menuLeft = document.getElementById('cbp-spmenu-s1');
	$(".g-sidec").hover(//菜单hover
	function() {
		classie.toggle(this, 'active');
		classie.toggle(menuLeft, 'cbp-spmenu-open');
		disableOther('showLeft');
		$("#cbp-spmenu-s1").toggleClass('menulicq');
		$("#showLeft").show();
		
	});
	$("#showLeft").hover(//三角按钮hover
	function() {
		classie.toggle(this, 'active');
		classie.toggle(menuLeft, 'cbp-spmenu-open');
		/*$("#cbp-spmenu-s1").addClass('menulicq');*/
		disableOther('showLeft');
		/*$("#showLeft").hide()*/
	}, function() {
	});
	function disableOther(button) {
		if (button !== 'showLeft') {
			classie.toggle(showLeft, 'disabled');
		}
	}
	$("#cbp-spmenu-s1").toggleClass('menulicq');

</script>
</html>